package com.ftd.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ftd.DBConnection.DBConnection;
import com.ftd.model.Ebook;
import com.ftd.model.Mark;
import com.ftd.viewmodel.MapResult;
import com.oracle.javafx.jmx.json.impl.JSONMessages;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by apple on 16/7/30.
 */
@RestController
public class MarkViewController {
    @RequestMapping("getMarkJson.do")
    public List<MapResult> getEbookJson() throws IOException {

        List<MapResult> mapList = new ArrayList<MapResult>();

        ArrayList list = (ArrayList) DBConnection.select2("markTable_2");
        for (int i = 0; i < list.size();i++) {
            Mark mark = (Mark)list.get(i);
            MapResult mapResult = new MapResult();
            mapResult.put("title", mark.getmTitle());
            mapResult.put("imageUrl", mark.getmImageUrl());
            mapResult.put("type", mark.getmType());
            mapResult.put("reading", mark.getmCount());
            mapList.add(mapResult);
        }

        return mapList;
    }

    @RequestMapping(value = "markView.do")
    public String markView(){
        return "markView";
    }

}
